﻿using IPC.ListConnect.Connect;
using IPC.LogCommon.log4net;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IPC.WinForm.Controller
{
    [ApiController]
    [Route("[controller]")]
    public class WriteValuesController : ControllerBase
    {
        /// <summary>
        /// 多标签写
        /// </summary>
        /// <param name="connectName">通道名</param>
        /// <param name="equipName">设备名</param>
        /// <param name="values">值 格式为["test1","test2"]</param>
        /// <param name="startTag">开始写入标签名，默认从第一个开始写</param>
        /// <param name="groupName"></param>
        /// <returns></returns>
        [HttpGet(Name = "Write")]
        public async Task<string> Post(string connectName,string equipName,string values,string startTag = "",string groupName="")
        {
            LogClass.Instance.Info($"ReadValuesController:connectName{connectName},equipName{equipName},startTag{startTag},values{values},groupName{groupName}");
            string json = ConnectList.Instance.WriteByJson(connectName, equipName, values, startTag, groupName);
            return await Task.FromResult(json);
        }
    }
}
